layui.define(['Mock', 'apiAuth', 'qs'], function (exports) {
	var Mock = layui.Mock,
		api = layui.apiAuth.api,
		qs = layui.qs;


	function authMock() {
		Mock.setup({
			timeout: '50-100'
		})

		/**
		 * @author: ares
		 * @date: 2020/2/2 19:24
		 * @description: 登录
		 */
		Mock.mock(RegExp(api.login + '[^\.]*$'), function (options) {
			var params = qs.parse(options.url.split('?')[1]),
				body = JSON.parse(options.body);
				result = {};
			if (params.username == 'admin' && params.password == 'admin' && params.code == 'jgmxj') {
				result = Mock.mock({
					code: 2000,
					msg: '登录成功',
					data: '@string("upper", 32)'
				})
			} else {
				result.code = 1000;
				result.data = null;
				result.msg = '用户名/密码/验证码错误';
			}
			return result;
		})

		/**
		 * @author: ares
		 * @date: 2020/2/2 20:49
		 * @description: 退出登录
		 */
		Mock.mock(RegExp(api.logout + '[^\.]*$'), 'delete', function (options) {
			return {
				code: 2000,
				msg: '退出成功'
			};
		})

		Mock.mock(RegExp(api.modifyPwd + '[^\.]*$'), 'put', function (options) {
			return {
				code: 2000,
				msg: '密码修改成功'
			};
		})
	}

	exports("authMock", authMock);
})